// JavaScript Document

function validate(){
	
var empno = document.getElementById('txtEmpno');	
//var year = document.getElementById('sltYr');	
//var month = document.getElementById('sltMon');	
var date = document.getElementById('txtDt');	
var inn = document.getElementById('sltIn');	
var out = document.getElementById('sltOut');


if(notEmpty(empno, "Employee Number cannot be empty")){
	if(isNumeric(empno, "Employee Number should be numeric ")){
		//if(madeSelection(year, "Select the year")){
			//if(madeSelection(month, "Select the month")){
	             if(notEmpty(date, "Select the date")){
					 if(madeSelection(inn, "Select in time")){
	                      if(madeSelection(out, "Select the out time")){
	
	                                loadXMLDoc();
	
			                 }
					   return false;
					   //}
				 //return false;
				 //}
		     //return false;
			 }
		return false;
		}
	 return false;
	}
	return false;
}
	
	
	return false;
}
	
	
	
	
	
	function loadXMLDoc()
{


if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
		
    document.getElementById("ajaxDiv").innerHTML=xmlhttp.responseText;
	document.getElementById("myForm").reset(); 
	
    }
  }

                var empno = document.getElementById('txtEmpno').value;	
                //var year = document.getElementById('sltYr').value;	
                //var month = document.getElementById('sltMon').value;	
                var date = document.getElementById('txtDt').value;	
                var inn = document.getElementById('sltIn').value;	
                var out = document.getElementById('sltOut').value;
	
	var queryString ="?empno=" + empno + "&date="+date+ "&in=" + inn +
	"&out="+out;
	
xmlhttp.open("GET","../logic/add/att_employee_add.php"+queryString ,true);
xmlhttp.send();
}

function checkempno(){

var empno = document.getElementById('txtEmpno');	

if(notEmpty(empno, "Employee Number cannot be empty")){
 
 if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
   xmlhttp=new XMLHttpRequest();
    }
  else
   {// code for IE6, IE5
 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
     }
    xmlhttp.onreadystatechange=function()
     {
 if (xmlhttp.readyState==4 && xmlhttp.status==200)
  {
									//document.getElementById("ajaxDiv").innerHTML=xmlhttp.responseText; 
									 
   var x=xmlhttp.responseText;
if(x=="false"){
									
  document.getElementById("ajaxDiv1").innerHTML="Invalid Employee No";
  document.getElementById('txtEmpno').value="";
	}else{
  document.getElementById("ajaxDiv1").innerHTML=x; 
									
			}
			}
            }
								
  var y=document.getElementById('txtEmpno').value;
  var queryString ="?empno=" + y;
  xmlhttp.open("GET","../logic/load/check_emp.php"+queryString,true);
  xmlhttp.send();	  
	
	
}
}
	
		function clearx()
{
	
	 document.getElementById("myForm").reset(); 
     document.getElementById("ajaxDiv").innerHTML="";
	 document.getElementById("ajaxDiv1").innerHTML="";
}